import sys

def feasible_partition(a, n, k, L, R):
    parts = []
    cur_l = 1   # 1-based
    got_good = False
    made = 0

    i = 1
    while i <= n:
        x = a[i-1]
        if x > R:
            # 必须在 i-1 截断；若当前段还没包含 [L,R] 元素 -> 不可行
            if not got_good:
                return False, None
            parts.append((cur_l, i-1))
            made += 1
            if made == k-1:
                # ✅ 修正：最后一段起点应跳过这个 >R 的元素
                last_l = i + 1
                if last_l > n:
                    return False, None
                has_good = False
                for y in a[last_l-1:]:
                    if y > R:
                        return False, None
                    if L <= y <= R:
                        has_good = True
                if not has_good:
                    return False, None
                parts.append((last_l, n))
                return True, parts
            # 开启新段，从 i+1 开始（跳过 >R）
            cur_l = i + 1
            got_good = False
            i += 1
            continue

        # x <= R
        if L <= x <= R and made < k-1:
            # 前 k-1 段：遇到第一个好元素就截断，保证字典序最小
            parts.append((cur_l, i))
            made += 1
            cur_l = i + 1
            got_good = False
            if made == k-1:
                if cur_l > n:
                    return False, None
                has_good = False
                for y in a[cur_l-1:]:
                    if y > R:
                        return False, None
                    if L <= y <= R:
                        has_good = True
                if not has_good:
                    return False, None
                parts.append((cur_l, n))
                return True, parts
        else:
            if L <= x <= R:
                got_good = True
        i += 1

    # 扫描结束：若正好做了 k-1 段，则最后一段为 [cur_l, n]
    if len(parts) == k-1:
        if cur_l > n:
            return False, None
        has_good = False
        for y in a[cur_l-1:]:
            if y > R:
                return False, None
            if L <= y <= R:
                has_good = True
        if not has_good:
            return False, None
        parts.append((cur_l, n))

        return True, parts

    return False, None


def solve_one(n, k, a):
    vals = sorted(set(a))
    m = len(vals)
    best_width = None
    best_parts = None

    j = 0
    for i in range(m):
        if j < i:
            j = i
        while j < m:
            L, R = vals[i], vals[j]
            ok, parts = feasible_partition(a, n, k, L, R)
            if ok:
                width = R - L
                if (best_width is None) or (width < best_width) or \
                   (width == best_width and parts < best_parts):
                    best_width = width
                    best_parts = parts
                break
            j += 1
        if best_width == 0:
            break

    if best_parts is None:
        # 理论上不会走到这里（[min(a), max(a)] 总可行）
        base, rem = n // k, n % k
        parts = []
        l = 1
        for t in range(k):
            r = l + base - 1 + (1 if t < rem else 0)
            parts.append((l, r))
            l = r + 1
        return parts
    
    return best_parts



def main():
    t = int(input())
    for _ in range(t):
        n, k = map(int, input().split())
        a = list(map(int, input().split()))
        ans = solve_one(n, k, a)
        for l, r in ans:
            print(f"{l} {r}")

if __name__ == "__main__":
    main()



#测试数据：
"""
1
6 3
8 3 5 6 4 3
"""